package com.atstudent.gmall.common.feign.interceptor;

import com.atstudent.gmall.common.feign.util.AuthUserInfoUtils;
import com.atstudent.gmall.common.feign.util.HttpServletRequestThreadLocal;
import feign.RequestInterceptor;
import feign.RequestTemplate;
import lombok.extern.slf4j.Slf4j;

import javax.servlet.http.HttpServletRequest;

/**
 * @Author 薛有朋
 * @CreatDate 2025/4/12 20:53
 **/
@Slf4j
public class FeignClientInterceptor implements RequestInterceptor {
    @Override
    public void apply(RequestTemplate requestTemplate) {
        log.info("RequestInterceptor.....apply执行了");

        AuthUserInfo authUserInfo = AuthUserInfoUtils.getAuthUserInfo();
        if (authUserInfo != null){
            requestTemplate.header("userId" , authUserInfo.getUserId());
            requestTemplate.header("userTempId" , authUserInfo.getUserTempId());
        }
    }
}
